import config from "@/config"
import http from "@/utils/request"

// 数据字典
export default {
  // 字典分类
  getDictionaryList: {
    url: `${config.API_URL}/dictsort/list`,
    name: "获取数据字典列表",
    get: function () {
      return new Promise((resolve, reject) => {
        http.get(this.url).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  addDictionary: {
    url: `${config.API_URL}/dictsort/add`,
    name: "添加数据字典",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.post(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  updateDictionary: {
    url: `${config.API_URL}/dictsort/update`,
    name: "修改数据字典",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.post(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  deleteDictionary: {
    url: `${config.API_URL}/dictsort/delete`,
    name: "删除数据字典",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.postParam(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  // 字典键值列表
  getDictionaryTypeList: {
    url: `${config.API_URL}/dictsortDetail/list`,
    name: "获取数据字典分类",
    get: function (data) {
      return new Promise((resolve, reject) => {
        http.get(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  getDictionaryByCode: {
    url: `${config.API_URL}/dictsortDetail/detailList`,
    name: "跟进code获取字典明细",
    get: function (data) {
      return new Promise((resolve, reject) => {
        http.get(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  addDictionaryValue: {
    url: `${config.API_URL}/dictsortDetail/add`,
    name: "添加数据字典键值",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.post(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
  updateDictionaryValue: {
    url: `${config.API_URL}/dictsortDetail/update`,
    name: "修改数据字典键值",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.post(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  deleteDictionaryValue: {
    url: `${config.API_URL}/dictsortDetail/delete`,
    name: "删除数据字典键值",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.postParam(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  deleteBatchDictionaryValue: {
    url: `${config.API_URL}/dictsortDetail/deleteBatch`,
    name: "批量删除数据字典键值",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.postParam(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },




}
